class UsersController < ApplicationController
  before_filter :authenticate, :except => [:new, :create, :login_box]
  
  def index
    @users = User.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @users }
    end
  end
  
  def show
    @user = User.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @user }
    end
  end
  
  def new
    @user = current_user
  end
  
  def create
    @user = current_user
    if @user.save
      redirect_to users_path, :notice => 'User successfully added'
    else
      render :action => 'new'
    end
  end
  
  def edit
    @user = User.find(params[:id])    
  end
  
  def update 
    @user = User.find(params[:id]) 
    if @user.update_attributes(params[:user]) 
      redirect_to users_path, :notice => 'Updated user information successfully.' 
    else 
      render :action => 'edit'
    end
  end
  
  def welcome
    @current_user = current_user if !current_user.nil?
  end
end
